package com.sunfeng.mianshi;

/**
 * @Author : 清风冷影
 * @Description:
 * @Date : 2021/11/18  20:23
 */
public class Singleton {

    private volatile static Singleton singleton = null;

    private Singleton (){

    }
    /**
     * 懒汉式
     * @return
     */
    public static Singleton getInstance() {

        if (singleton == null) {
            synchronized (Singleton.class) {
                if (singleton == null) {
                    synchronized (Singleton.class) {
                        singleton = new Singleton();
                    }
                }
            }
        }

        return singleton;
    }
}
